package com.rakuten.api.mule.transformers;

import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;

import com.rakuten.api.mule.CommonFlowConstants;

//import com.rakuten.api.mule.exceptions.InboundPropertyNotFoundException;

/**
 * Validate input parameters and set MuleMessage.
 * 
 * @author saito_shinya@ogis-ri.co.jp
 */
public class InitializationParameters extends AbstractMessageTransformer {

	public InitializationParameters() {
		super();
		// this.registerSourceType(DataTypeFactory.create(Product.class));
		// setReturnDataType(DataTypeFactory.create(Map.class));
	}

	@Override
	public Object transformMessage(MuleMessage message, String outputEncoding)
			throws TransformerException {
		// Set original payload to session variable

		try {
			// get mearchantId
			String merchantId = message
					.getInboundProperty(CommonFlowConstants.MERCHANT_ID);
			
			// get baseSku
			String baseSku = message
					.getInboundProperty(CommonFlowConstants.BASE_SKU);

			message.setProperty(CommonFlowConstants.MERCHANT_ID, merchantId,
					PropertyScope.SESSION);

			message.setProperty(CommonFlowConstants.BASE_SKU, baseSku,
					PropertyScope.SESSION);
			
			
			return message;
		} catch (Exception ex) {
			throw new TransformerException(this, ex);
		}
	}
	/**
	 * TODO Temporary implementation. implements MongoDB version.
	 */

}
